home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Memory / PlatfMem.h < prev   
Encoding:
C/C++ Source or Header  |  1996-08-28  |  3.7 KB  |  135 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        PlatfMem.h
  3.  
  4.     Contains:    Platform layer interfaces
  5.  
  6.     Owned by:    Jens Alfke
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.     
  12.         <13>    10/14/95    TJ        Updated decleration of SOMPrintf to new Mac
  13.                                     SOM decleration
  14.         <12>      6/1/95    jpa        Restored <11>: Changed def of highest
  15.                                     possible address, for VM compatibility
  16.                                     [1249619]
  17.         <11>     5/17/95    TJ        Backed out changes from previous checkin.
  18.          <9>      5/4/95    jpa        Added MinFreeSpace consts [1235657]
  19.          <8>     9/29/94    RA        1189812: Mods for 68K build.
  20.          <7>     9/14/94    jpa        Eliminated dependencies on rest of OpenDoc.
  21.                                     [1186692]
  22.          <6>     8/17/94    jpa        Improved assertion and print-string macros.
  23.          <5>      8/8/94    jpa        #ifdef OD_DEBUG --> #if ODDebug
  24.          <4>     6/22/94    NP        Cast for PPCC.
  25.          <3>     6/21/94    jpa        Fixed PLATFORM... macros to compile w/o
  26.                                     warnings from CodeWarrior.
  27.          <2>     6/10/94    MB        Make it build
  28.          <1>      6/9/94    MB        first checked in
  29.          <2>      5/9/94    MB        #1162181: Changes necessary to install MMM.
  30.          <1>     4/29/94    MB        first checked in
  31.     To Do:
  32.     In Progress:
  33.         
  34. */
  35.  
  36. #ifndef _PLATFMEM_
  37. #define _PLATFMEM_
  38.  
  39. #ifndef _MEMCNFIG_
  40. #include "MemCnfig.h"
  41. #endif
  42.  
  43. #ifndef _MEMMGR_
  44. #include <MemMgr.h>
  45. #endif
  46.  
  47. #include <stddef.h>
  48.  
  49. #ifndef __MEMORY__
  50. #include <Memory.h>
  51. #endif
  52.  
  53.  
  54. //========================================================================================
  55. // Defines
  56. //========================================================================================
  57.  
  58. #ifndef __MWERKS__
  59.     #define _FIL_ ""            /* MPW puts entire pathnames in; yuk! */
  60. #else
  61.     #define _FIL_ __FILE__
  62. #endif
  63.  
  64. #define MM_ASSERT(condition)    \
  65.     if(!MM_DEBUG || (condition)) ; else MM_ASSERT_FAILED( #condition, _FIL_ )
  66.  
  67. #define MM_WARN    \
  68.     if(!MM_DEBUG) ; else MM_SHOW_WARNING
  69.  
  70. #define MM_PRINTING    0        // Set to 1 to enable MM_PRINT
  71.  
  72. #define MM_PRINT if( !MM_PRINTING ) ; else somPrintf
  73.  
  74.  
  75. //========================================================================================
  76. // Types
  77. //========================================================================================
  78.  
  79. typedef unsigned long    MMULong;
  80.  
  81. #ifdef __xlC
  82. typedef unsigned long SIZE_T;
  83. #else
  84. typedef size_t SIZE_T;
  85. #endif
  86.  
  87.  
  88.  
  89. //========================================================================================
  90. // Constants
  91. //========================================================================================
  92.  
  93. const MMBoolean kMMFalse = 0;
  94. const MMBoolean kMMTrue  = 1;
  95.  
  96. #define            kMMNULL        (0)
  97.  
  98. const size_t    kPlatformMinFreeSpace    = 64 * 1024;    // Leave this much free
  99. const size_t    kPlatformMinContigSpace    = 32 * 1024;    // Leave this size block available
  100.  
  101.  
  102. //========================================================================================
  103. // Global function declarations
  104. //========================================================================================
  105.  
  106. /* Adkins -- removed const from first param to somPrintf -- it was never const */
  107. extern "C" int somPrintf (const char * fmt, ...);        // From <somapi.h>
  108.  
  109. void PlatformZapMem( void *start, size_t size, MMULong value );
  110. void *PlatformAllocateBlock(size_t size, MMHeapLocation);
  111. void PlatformFreeBlock(void *ptr);
  112.  
  113. void MM_ASSERT_FAILED(const char *cond, const char *fil);
  114. void MM_SHOW_WARNING(const char *msg, ...);
  115.  
  116. //----------------------------------------------------------------------------------------
  117. // PlatformCopyMemory
  118. //----------------------------------------------------------------------------------------
  119.  
  120. inline void PlatformCopyMemory(void *source, void *destination, size_t length)
  121. {
  122.     BlockMoveData(source, destination, (Size) length);
  123. }
  124.  
  125. #if MM_DEBUG
  126.  
  127. #define LOWEST_POSSIBLE_ADDRESS()    ((void*) &SystemZone()->heapData)
  128. #define HIGHEST_POSSIBLE_ADDRESS()    ((void*) gTotalMemory)
  129.  
  130. extern size_t gTotalMemory;
  131.  
  132. #endif
  133.  
  134. #endif
  135.